package com.dpp.mapper;

import com.dpp.entity.ActivityRecord;
import org.apache.ibatis.annotations.*;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface ActivityRecordMapper {
    @Select("SELECT * FROM  activity_record WHERE openid=#{openId}")
    List<ActivityRecord> selectByOpenid(String openId);
    @Insert("insert into activity_record( activity_id,openid, record_start_time, record_end_time, Record_finished) VALUES ( #{activityId} ,#{openId} ,#{recordStartTime} ,#{recordEndTime} ,#{RecordFinished} )")
    void insert(ActivityRecord activityRecord);
    @Delete("DELETE FROM activity_record where openid=#{openid}")
    void deleteByOpenid(String openid);
    @Delete("DELETE FROM activity_record where openid=#{openid} and activity_id=#{ActivityId} ")
    void deleteByOpenidActivity(String openid,Integer ActivityId);
    @Update("update activity_record set Record_finished = 1 ,record_end_time=#{now} where openid=#{openId} and activity_id=#{activityId}")
    void updateEndRecord(Integer activityId, LocalDateTime now, String openId);
    @Select("SELECT * FROM  activity_record WHERE openid=#{openid} and  activity_id =#{activityId}")
    ActivityRecord selectByActivityId(String openid, Integer activityId);
    @Select("SELECT * FROM  activity_record WHERE openid=#{openId} and Record_finished=#{finished}")
    List<ActivityRecord> selectByListOpenid(String openId, Integer finished);
}
